home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / FREXP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  427 b   |  21 lines

  1. /* frexp.c FUNCTION, FROM P. 215 OF TURBO C BIBLE */
  2. #include<stdio.h>
  3. #include<math.h>
  4. #include<stdlib.h>            /* errno is defined here */
  5. main(int argc, char **argv)
  6. {
  7.     int exponent;
  8.     double x, mantissa;
  9.  
  10.     if(argc < 2)
  11.     {
  12.     printf("Usage %s <x> \n", argv[0]);
  13.     }
  14.     else
  15.     {
  16.         x = atof(argv[1]);
  17.         mantissa = frexp(x, &exponent);
  18.         printf("%s = %f times 2 raised to %d\n",
  19.                 argv[1], mantissa, exponent);
  20.     }
  21. }